﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Avatar.MembershipService;
using AvatarHelper;

public partial class PersonHome : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        PersonHelper.BasicInformationJobIntentionCheck();
        var _user = LoginManager.GetCurrentUser();
        if (_user != null)
        {
            using (var _adc = DBHelper.GetDataContext())
            {
                var _resume = _adc.Resume.Where(r => r.User == _user.UserName).FirstOrDefault();
                if (_resume != null)
                {
                    lbl_ResumeUpdateDate.Text = string.IsNullOrEmpty(_resume.UpdateDate.ToString()) ? "----" : Convert.ToDateTime(_resume.UpdateDate).ToShortDateString();
                    lbl_ViewCount.Text = _resume.ViewCount.ToString();
                    link_Review.Text = "简历预览";
                    link_Review.NavigateUrl = "ResumeView.aspx?user=" + _resume.User;
                    link_Review.Target = "_blank";

                    li_BasicInfo.Attributes.Add("Class", "ok");
                    if (_resume.PersonalBasicInfo == null)
                    {
                        li_BasicInfo.Attributes.Add("Class", "blank");
                    }

                    li_SelfEvaluation.Attributes.Add("Class", "ok");
                    if (_resume.SelfEvaluation == null)
                    {
                        li_SelfEvaluation.Attributes.Add("Class", "blank");
                    }

                    li_JobIntention.Attributes.Add("Class", "ok");
                    if (_resume.JobIntention == null)
                    {
                        li_JobIntention.Attributes.Add("Class", "blank");
                    }

                    li_WorkExperience.Attributes.Add("Class", "ok");
                    if (_resume.WorkExperience.Count() < 1)
                    {
                        li_WorkExperience.Attributes.Add("Class", "blank");
                    }

                    li_Education.Attributes.Add("Class", "ok");
                    if (_resume.Education.Count < 1)
                    {
                        li_Education.Attributes.Add("Class", "blank");
                    }

                    li_Training.Attributes.Add("Class", "ok");
                    if (_resume.TrainingExperience.Count < 1)
                    {
                        li_Training.Attributes.Add("Class", "blank");
                    }
                }
            }
        }
    }
    protected void btn_LogOut_Click(object sender, EventArgs e)
    {
        LoginManager.Logout();
    }
}
